<!-- 提交订单 -->
<template>
	<view class="order">
		<view class="order_content">
			<view class="list">
				<view class="order_top">
					<view class="top_card_left1" v-show="!userinfo.length" @click="toPage('/pages/user/address/index')">
						<view class="top_card_place">请添加收货地址</view>
					</view>
					<view class="top_card_left" :index="index" v-for="(item, index) in userinfo" @isUserinfo="isUserinfo" :key="item.id">
						<span>{{item.type}}</span>
						<p>{{item.address}}</p>
						<view class="top_card_room">{{item.room}}</view>
						<view class="top_card_user">用户ID</view>
						<view class="top_card_phone">{{item.phone}}</view>
					</view>
					<image src="/static/img/common_ic_04.png"  ></image>
				</view>
				<view class="order_card" :index="index" v-for="(item, index) in goods_store" :key="item.id">
					<view class="order_left">
						<image :src="item.img" alt mode="aspectFit" class="order_photo"></image>
					</view>
					<view class="order_right">
						<view class="order_title">
							<p>{{ item.title }}</p>
							<span>{{ item.price }}积分</span>
						</view>
						<view class="card_calculation">
							<number-box v-model="item.value" bg-color="#fff" min="1" input-width="48" color="#BBBBBB" max="99" size="24rpx"
							 @change="valChange"></number-box>
						</view>
					</view>
				</view>
				<view class="order_middle">
					<view class="middle_first" @click="toPage(outlets_url)">
						<p>兑换网点</p>
						<input type="text" value="" placeholder="请选择商品的兑换网点" :disabled="true"/>
						<image src="/static/img/common_ic_04.png" mode="aspectFit"></image>
					</view>
					<view class="middle_line"></view>
					<view class="middle_two">
						<p>员工码</p>
						<input type="text" value="" placeholder="请输入员工码" />
					</view>
				</view>
			</view>
			<view class="order_bottom">
				<span>{{sum_store}}积分</span>
				<view class="order_bottom_btn">
					<view class="order_cart">
						<view class="swap_text">加入购物车</view>
					</view>
					<view class="swap">
						<view class="swap_text">立即兑换</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				outlets_url:"/pages/outlets/index",
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#FF5445',
					}
				}],
				address_url: "/pages/user/address/add/index",
				userinfo: [
					// 	{
					// 	id: 0,
					// 	type: "默认",
					// 	address: "福建省泉州市丰泽区东海泰禾广场13栋",
					// 	room: "1208室",
					// 	phone: "131***9900",
					// },
				],
				disabled: false,
				show: false,
				value: 0,
				// sum_store: [],
				checked: false,
				order_group: [{
						id: 1,
						img: "/static/img/1.png",
						title: "九阳迷你形家用电磁炉三年全国保修",
						text: "8800积分",
						select: "/static/img/common_ic_12_selected.png",
						price: 1,
						value: "",
						name: '',
						checked: false,
						disabled: false,
						show: false,
					},
					{
						id: 2,
						img: "/static/img/1.png",
						title: "九阳迷你形家用电磁炉三年全国保修",
						text: "8800积分",
						select: "/static/img/common_ic_12_selected.png",
						price: 2,
						value: "",
						name: '',
						checked: false,
						disabled: false,
						show: false,
					},
				],
			};
		},
		watch: {},
		computed: {
			...mapState({
				sum_store: state => state.order.sum,
				goods_store: state => state.order.goods,
			})
		},
		methods: {
			toPage(val) {
				uni.navigateTo({
					url: val
				})
			},
			// 选中某个复选框时，由checkbox时触发
			checkboxChange(e) {
				//console.log(e);
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				// console.log(e);
			},
			// 全选
			checkedAll() {
				this.order_group.map(val => {
					val.checked = true;
				})
			},
			valChange() {

			},
			click(index) {
				this.order_group.splice(index, 1);
				this.$u.toast(`删除了第${index+1}个商品`);
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.list[index].show = true;
				this.list.map((val, idx) => {
					if (index != idx) this.list[idx].show = false;
				})
			}
		},
		beforeCreate() {},
		created() {},
		beforeMount() {},
		mounted() {
			// console.log("111111");
			// this.userinfo.map((item ,index) =>{
			// 	if(!item.length){
			// 	console.log("当前的数组长度是：",this.userinfo.length)
			// 	// console.log("aaa",this.aaa)
			// 	}else{
			// 		console.log("当前用户没有添加地址")
			// 	}
			// })
			// console.log(this.userinfo.length);
		},
		beforeUpdate() {},
		updated() {},
		beforeDestroy() {},
		destroyed() {},
	};
</script>
<style scoped lang='scss'>
	@import "./index.scss";
</style>
